
<div class="joincampform">
	<h3>我要购买 <span>请如实填写下面信息，我们的服务人员会联系您，详细介绍购买详情。</span></h3>
	<form action="/web/buycar" method="post" id="form1">
		<div class="form-group-input">
			<label>您的称谓</label>
			<input type="text" name="name" placeholder="请填写您的名字">
		</div>
		<div class="form-group-input">
			<label>手机号码</label>
			<input type="text" name="phone" placeholder="请填写联系电话">
		</div>
		<div class="form-group-input" placeholder="请填写邮箱地址">
			<label>邮箱</label>
			<input type="text" name="email" placeholder="请填写邮箱地址">
		</div>
		<div class="form-group-input"  id="ad">
			<label for="" class="form-label">通讯地址</label>
			<select name="addressCountry" id="addressCountry" class="addressCountry" data-first-title="选择国家" data-url="/web/country"   style="width:100px;" ></select>
			<select name="addressProvince" id="addressProvince" class="addressProvince" data-first-title="选择省" data-url="/web/province"  style="width:100px;"></select>
		    <select name="addressCity" id="addressCity" class="addressCity" data-first-title="选择城市"  data-url="/web/city"  style="width:100px;"></select>
	        <input type="text" name="address" placeholder="请填写详细地址">
		</div>
		<!-- <input type="hidden" name="type" value="buy"> -->
		<div class="form-group-input">
			<button type="button" id="aa">提交</button>
		</div>
	</form>
</div>
<!-- 世界城市地区联动 -->
<script src="/js/jquery.cxselect.js"></script>
<script>
	$('#ad').cxSelect({
	selects: ['addressCountry','addressProvince', 'addressCity','addressCamp'],
	jsonName: 'area_name',
	jsonValue: 'area_code'	}, function(api) {
	  cxSelectApi = api;
	});
</script>
<script type="text/javascript">
  $(document).ready(function(){
        //提交表单
        $("#aa").click(function(){
        	var obj1=document.getElementById("addressCountry");
        	var obj2=document.getElementById("addressProvince");
        	var obj3=document.getElementById("addressCity");
  			$('#form1').append('<input type="hidden" name="country" value="'+ obj1.options[obj1.selectedIndex].text+'" />');
  			$('#form1').append('<input type="hidden" name="province" value="'+obj2.options[obj2.selectedIndex].text+'" />');
  			$('#form1').append('<input type="hidden" name="city" value="'+obj3.options[obj3.selectedIndex].text+'" />'); 
	        $("#form1").attr('action','/web/buycar');
	        $("#form1").submit();
          });
    });  
</script>
<script type="text/javascript">
	$(function(){
		//邮箱
		$("input[name='email']").blur(function(){
			var email = $('input[name="email"]').val();
			//不能为空
			if(!$.trim(email)) {
				$("input[name='email']").css({border: "1px solid red"});
				$("#emailerror").html("必填");
				return false;
			}else{
				$.get('/reserve/checkemail?email='+$("input[name='email']").val(),function(data) {
					$("input[name='email']").css({border: "1px solid green"});
					$("#emailerror").html("");
					if (data===0) {
						$("input[name='email']").css({border: "1px solid red"});
						$("#emailerror").html("格式不正确");
					}
				});
			}
		})
		//手机格式
		$("input[name='phone']").blur(function(){
			var phone = $('input[name="phone"]').val();
			//不能为空
			if(!$.trim(phone)) {
				$("input[name='phone']").css({border: "1px solid red"});
				$("#phone_error").html("必填");
				return false;
			}
			//手机号格式是否满足
			if((/^1[3|4|5|7|8]\d{9}$/.test(phone)) || (/(^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+$)|(^$)/.test(phone))){
				$("input[name='phone']").css({border: "1px solid green"});
				$("#phone_error").html("");
			}else {
				$("input[name='phone']").css({border: "1px solid red"});
				$("#phone_error").html("格式不正确");
				return false;
			}
		})
	})
</script>


                            